<template>
	<view>
		<u-toast ref="uToast"></u-toast>
		<view class="u-p-10">
			<u--textarea height="130" v-model="intro"  confirmType="done" :placeholder="fillintroductionText" count maxlength="90"></u--textarea>
		</view>
		<view class="goshop-bt-x-10 u-m-t-20">
			<u-button type="error" size="large" @click="submit" :text="saveText"></u-button>
		</view>
	</view>
</template>

<script>
	import {updateIntro} from '@/common/http.api.js'
	export default {
		data() {
			return {
				intro:'',
				saveText:'',
				updatesuccessText:'',
				updatefailText:'',
				fillintroductionText:'',
			};
		},
		onShow(){
			this.refresh();
		},
		onLoad(e){
			this.intro = e.intro;
		},
		methods:{
			refresh(){
				this.saveText = this.$t('common.save.text');
				this.updatesuccessText = this.$t('common.updatesuccess.text');
				this.updatefailText = this.$t('common.updatefail.text');
				this.fillintroductionText = this.$t('introduction.fillintroduction.text');
			},
			submit() {
				let that = this;
				updateIntro({params: {intro: this.intro}}).then(res => {
					if (res.code === 0) {
						this.$refs.uToast.show({
							message: that.updatesuccessText,
							type: 'success',
							complete() {
								uni.navigateBack({
									delta: 1
								});
							}
						})
						uni.hideLoading();
					} else {
						uni.hideLoading();
						uni.showModal({
							showCancel: false,
							title: that.updatefailText,
							content: res.msg,
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">

</style>